\begin{tikzpicture} [every node/.style={anchor=south,,inner sep=0}]
	\node (program){
		\begin{tabular}{l}
			program P;\\
            \quad  var $a$, $x$ : integer;\\
            \quad  procedure Q($b$: integer); \\
            \quad \quad var $i$: integer;\\
            \quad \quad procedure R($u$: integer; var $v$: integer);\\
            \quad \quad \quad var $c$, $d$: integer;\\
            \quad \quad \quad begin\\
            \quad \quad \quad \quad if $u=1$ then $u=u+1$;\\
            \quad \quad \quad \quad \quad \dots\dots\\
            \quad \quad \quad \quad $v:= (a+c)+(b-d)$;\\
            \quad \quad \quad \quad \dots\dots\\
            \quad \quad \quad end \{R\}\\
            \quad \quad begin\\
            \quad \quad \quad \dots\dots\\
            \quad \quad \quad R$(i, x)$;\\
            \quad \quad \quad \dots\dots\\
            \quad \quad end \{Q\}\\
            \quad procedure S;\\
            \quad \quad var $c, i$: integer;\\
            \quad \quad begin\\
            \quad \quad \quad $a:=1$;\\
            \quad \quad \quad Q$(c)$;\\
            \quad \quad \quad \dots\dots\\
            \quad \quad end \{S\}\\
            \quad begin\\
            \quad \quad $a:=0$; \\
            \quad \quad S;\\
            \quad \quad \dots\dots\\
            \quad end.\\
	    \end{tabular}
    };	
    \draw ([xshift=0em,yshift=16.8em]program.west) -|([xshift=-2em,yshift=-16.8em]program.west) --++(3em,0);
    \draw ([xshift=1em,yshift=14.4em]program.west) -|([xshift=-1em,yshift=-2.4em]program.west) --++(3em,0);
    \draw ([xshift=1em,yshift=-3.6em]program.west) -|([xshift=-1em,yshift=-10.8em]program.west) --++(3em,0);
    \draw ([xshift=2em,yshift=12em]program.west) -|([xshift=0em,yshift=3.6em]program.west) --++(3em,0);

    \draw ([xshift=-10em,yshift=16.8em]program.east) -|([xshift=12em,yshift=-16.8em]program.east) --++(-22em,0);
    \draw ([xshift=-6em,yshift=14.4em]program.east) -|([xshift=8em,yshift=-2.4em]program.east) --++(-14em,0);
    \draw ([xshift=-6em,yshift=-3.6em]program.east) -|([xshift=8em,yshift=-10.8em]program.east) --++(-14em,0);
    \draw ([xshift=0em,yshift=12em]program.east) -|([xshift=4em,yshift=3.6em]program.east) --++(-4em,0);

    \node at ([xshift=-2em,yshift=17em]program.west) { \color{red} 0};
    \node at ([xshift=-1em,yshift=14.6em]program.west) { \color{red} 1};
    \node at ([xshift=-1em,yshift=-3.4em]program.west) { \color{red} 1};
    \node at ([xshift=0em,yshift=12.2em]program.west) { \color{red} 2};
    \node at ([xshift=13.5em,yshift=0em]program.east) { \color{red} $a, x$};
    \node at ([xshift=9.5em,yshift=6em]program.east) { \color{red} $b, i$};
    \node at ([xshift=9.5em,yshift=-7.2em]program.east) { \color{red} $c, i$};
    \node [align=center] at ([xshift=5.5em,yshift=7em]program.east) { \color{red} $u, v$ \\ \color{red}$c, d$};

\end{tikzpicture}